<template>
	<view class="">
		<view class="flex_nav">
			<view class="item1">
				<view class="header_info">
					<view @click="goPage('/pages/homepage/homepage')" hover-class="none">
						<image class="ph" :src="anchorInfo.avatar" mode="aspectFill"></image>
					</view>
					<view v-if="anchorInfo.first_name" class="name" @click="goPage('/pages/homepage/homepage')" hover-class="none" :style="{'max-width': maxWidth + 'rpx' }">
						<text class="text text_name">{{anchorInfo.first_name}}</text>
					</view>
					<view class="is_follow" v-if="!isOneself">
						<text v-if="isLike" class="text btn hover" @click="clickLike(anchorInfo.user_id)">
							已关注
						</text>
						<text v-else class="text btn" @click="clickLike(anchorInfo.user_id)">
							关注
						</text>
					</view>
				</view>
			</view>
			<view class="item2">
				<view class="header_more" @click="showPopup = true">
					<image class="ico_2" src="/static/img/ico_1.png" mode="widthFix"></image>
					<text class="name">更多推荐</text>
				</view>
			</view>
			<view class="item3">
				<view class="header_my"  @click="clickGoToMy">
					<image class="ico_2" src="/static/img/ico_2.png" mode="widthFix"></image>
				</view>
			</view>
			
		</view>
		<!-- <u-navbar leftIcon=" " bgColor="rgba(0,0,0,0)">
			<view class="home_header" slot="center">
				<view class="header_info">
					<navigator url="/pages/homepage/homepage" hover-class="none">
						<image class="ph" :src="anchorInfo.avatar" mode="aspectFill"></image>
					</navigator>
					<navigator v-if="anchorInfo.first_name" class="name" url="/pages/homepage/homepage" hover-class="none" :style="{'max-width': maxWidth + 'rpx' }">
						{{anchorInfo.first_name}}
					</navigator>
					<view v-if="!isOneself">
						<view v-if="isLike" class="btn hover" @click="clickLike(anchorInfo.user_id)">
							已关注
						</view>
						<view v-else class="btn" @click="clickLike(anchorInfo.user_id)">
							关注
						</view>
					</view>
				</view>
				<view class="header_more" @click="showPopup = true">

					<u-icon name="grid-fill" color="#fff" size="40rpx"></u-icon>
					<text class="name">更多推荐</text>
				</view>
				<view class="header_my"  @click="clickGoToMy">
					<u-icon name="account-fill" color="#fff" size="40rpx"></u-icon>
				</view>
			</view>
		</u-navbar> -->
		<!-- 	:isLoading="true"
				:poster="liveVideos[liveVideoIndex].video_img"
				:poster-for-crawler="liveVideos[liveVideoIndex].video_img" -->
		<view class="home_video" v-if="liveVideos && liveVideos[liveVideoIndex]">
			<DomVideoPlayer class="video_item" id="video_item"
				:enable-progress-gesture="false"  
				ref="pVideoVideoPlayer"
				objectFit="cover"
				:key="liveVideos[liveVideoIndex].live_id"
				:src="liveVideos[liveVideoIndex].video_url"
				:autoplay="true"
				:loop="false"
				:controls="false"
				:muted="isVoice == 1"
				:is-loading="true"
				:poster="liveVideos[liveVideoIndex].video_img"
				@play="videoPlay"
				@ended="videoEnded"
			>
			</DomVideoPlayer>
			
			<!-- <video class="video_item" :src="liveVideos[liveVideoIndex].video_url"
				
				object-fit="cover" 
				:controls="false" 
				:show-center-play-btn="false" 
				:autoplay="true" 
				:loop="true"
				:muted="isVoice == 1"
				:poster="liveVideos[liveVideoIndex].video_img"
				:poster-for-crawler="liveVideos[liveVideoIndex].video_img"
				@ended="videoEnded"
				@play="videoPlay"
			>
				<view v-if="isCoverPh" class="video_ph">
					<image v-if="liveVideos[liveVideoIndex].video_img" class="img" :src="liveVideos[liveVideoIndex].video_img" mode="aspectFill"></image>
					<image v-else class="img" :src="liveVideos[liveVideoIndex].video_url+'?x-oss-process=video/snapshot,t_7,f_jpg,w_720,h_1280,m_fast,ar_auto'" mode="aspectFill"></image>
				</view>
			</video> -->
			
		</view>
		
		
		<view class="text-box">
			<!-- 欢迎语 -->
			<view  class="welcome_box">
				<view class="welcome_ques" v-if="welcome">
				<text>问:</text>
				{{welcome}}
				</view>
			</view>
			
			<view  class="store_item" v-for="(item,index) in liveGoods" v-if="item.live_video_id == play_video_id">
				<store-product :appid="item.appid" :product-id="item.product_id" custom-content="true">
				<view class="store_ques" >
					<text>商品 ｜ </text>{{item.product_name}}
				</view>
				</store-product>
			</view>
			
			
			
			<view class="subtitle_ques" v-if="liveSubTitle">
				<text>简介:</text>
				{{liveSubTitle}}
			</view>
		</view>

		<view class="intellect" >
			<view class="title" style="display: none;">
				<view class="name">
					<view class="text">
						智能推荐
					</view>
					<image class="ico_3" src="/static/img/ico_3.png" mode="widthFix"></image>
				</view>
				<view class="btn" @click="showKeyboard">
					<image class="ico_4" src="/static/img/ico_4.png" mode="widthFix"></image>
					<view class="text">
						文字
					</view>
				</view>
				<view class="btn" @click="clickIsVoice(1)">
					<image class="ico_5" src="/static/img/ico_5.png" mode="widthFix"></image>
					<view class="text">
						语音
					</view>
				</view>
			</view>
			<view class="list">
				<view class="item" v-for="(item,index) in liveWords" :class="liveWordIndex == index?'hover':''" @click="clickliveWords(item, index)" :key="index" v-if="item.status != 1">
					{{item.title}} <image class="ico_lock" v-if="item.status == 2 && is_lock" src="/static/img/lock_btn.png" mode="widthFix"></image><image class="ico_lock" v-if="item.status == 2 && !is_lock" src="/static/img/unlock_btn.png" mode="widthFix"></image>
				</view>
			</view>
		</view>

		<!-- 聊天记录 -->
		<view class="chatting" v-if="isVoice == 1&&chattingData.length !=0">
			<!--  -->
			<scroll-view :scroll-top="scrollTop" :scroll-with-animation="true" scroll-y="true" :scroll-anchoring="true" class="scroll-Y" :scroll-into-view="scrollIntoView">
				<view class="item" v-for="(item,index) in chattingData" :key="index" :class="item.type == 0?'row_reverse':''">
					<image class="ph" :src="item.head" mode="aspectFill"></image>
					<view v-if="item.type == 0" class="text-right">
						{{item.content}}
					</view>
					<view v-if="item.type == 1" class="text-left">
						<text>{{item.name}}：</text>{{item.content}}<text v-if="item.content == '思考中'" class="three-dots"></text>
					</view>
				</view>
				<!-- 底部锚点 -->
				<view id="msg-bottom" style="height: 250rpx;"></view>
			</scroll-view>
			<image class="bg_img" src="/static/img/bg_3.png" mode="widthFix"></image>
		</view>
		
		<!-- 键盘输入 -->
		<view class="keyboard" v-if="focusKey" :style="{ 'bottom': keyboardInfo.height + 'px' }">
			<u-icon @click="isVoice = 1" name="volume" color="#ccc" size="40rpx"></u-icon>
			<input class="key_input" v-model="keyText" :adjust-position="false" :focus="focusKey" confirm-type="send"
				@blur="blurKey" 
				@confirm="confirmKey"
				@keyboardheightchange="keyboardheightchange"
			/>
		</view>
		
		<!-- 语音输入 -->
		<view class="voice" >
			
			<view class="btn_big" :class="isVoiceClass?'hover':''" @touchstart="voiceStart"
				@touchmove.stop.prevent="voiceMove" @touchcancel="voiceCancel" @touchend="voiceEnd">
				<image class="ico_13" src="/static/img/ico_13.png" mode="widthFix"></image>
				<view class="text">
					{{voiceText}}
				</view>
			</view>
			<!-- 提示 -->
			<view v-if="isVoiceClass" class="upglide_tip">
				<text>{{voiceTips}}</text>
				<!-- <image class="ico" src="/static/img/ico_sound_line.png" mode="widthFix"></image> -->
				<view class="prompt-loader">
					<view class="em" v-for="(item,index) in 7" :key="index"></view>
				</view>
			</view>
			
			<view class="btn-right" @click="showKeyboard">
				<image class="ico_14" src="/static/img/ico_14.png" mode="widthFix"></image>
			</view>
			
			<view class="btn-top-right" @click="mutedchange()" v-if="isVoice == 0 || chattingData.length ==0">
				
				<image class="ico_vioce" v-if="isVoice" src="/static/img/voice_mute.png"  mode="widthFix"></image>
				<image class="ico_vioce" v-else src="/static/img/voice_unmute.png"  mode="widthFix"></image>
			</view>
		</view>

		<!-- 右侧弹出框 -->
		<u-popup :show="showPopup" mode="right" :safeAreaInsetTop="true" bgColor="#000" overlayOpacity="0.9" @close="closePopup" @open="openPopup">
			<view class="more_scene">
				<view class="search">
					<image class="ico_ss" src="/static/img/ico_ss.png" mode="widthFix"></image>
					<input class="input_ss" v-model="liveName" type="text" placeholder="请输入推氪号或场景关键词" @confirm="getRecommendLivesList" />
					<button class="btn" @click="getRecommendLivesList">查找</button>
				</view>
				<view class="title">
					推荐场景
				</view>
				<u-empty v-if="aigcRecommendLives.length == 0" mode="search" marginTop="200rpx" icon="/static/img/ico_none.png" ></u-empty>
				<view v-else class="list">
					<view class="item" v-for="(item,index) in aigcRecommendLives" @click="clickRecommendLive(item.id)" :key="index">
						<image class="ph" :src="item.file" mode="aspectFill"></image>
						<view class="info">
							<view class="name">
								{{item.name}}
							</view>
							<view class="tag">
								{{item.sub_title}}
							</view>
						</view>
					</view>
				</view>
				
			</view>
		</u-popup>
		
		<!-- 提醒/弹出框 -->
		<u-popup :show="showExpend" mode="center" round="10" :safeAreaInsetBottom="false"  bgColor="#484848" overlayOpacity="0.7" @close="closeExpend">
			<view class="expend">
				<view class="num">
					<image class="ico" src="/static/img/lock_big.png" mode="widthFix"></image>
				</view>
				<view class="title">
					分享后即可查看
					
				</view>
				<view class="text">
					分享给好友或群聊，分享可解锁此场景全部内容，解锁后永久有效
				</view>
				
				<view class="btn">
					<!-- open-type="share" -->
					<button class="btn_item hover" @click="shareApp">
						立即分享，分享后即可解锁
					</button>
				</view>
			</view>
		</u-popup>
		

	</view>
</template>

<script>
	import DomVideoPlayer from "@/components/DomVideoPlayer/DomVideoPlayer.vue";
	// 录音
	const recorderManager = uni.getRecorderManager();
	const audio_base64 = '';
	// 语音回答
	const innerAudioContext = uni.createInnerAudioContext();
	
	export default {
		components: {
			DomVideoPlayer
		},
		data() {
			return {
				isFocus: false,
				isVoice: 0,
				showExpend:false,
				keyInput: null,
				showPopup: false,
				keyText: '',
				focusKey: false,
				voicePath: '',
				willStop: false,
				voiceText: '按住 说话',
				isVoiceClass: false,
				initPoint: {
					identifier: 0,
					Y: 0
				},
				voiceTips: '手指上滑取消发送',
				keyboardInfo:{},
				
				liveName: '',
				aigcRecommendLives:[],
				liveId:'',
				isPrivate:0,
				liveSubTitle:'',
				liveFile:'',
				token: '',
				userId: 0,
				
				oldLiveVideos: [],
				bgLiveVideos: [],
				simulateLiveVideos: [],
				liveVideos: [],
				liveVideoIndex: 0,
				
				liveWords: [],
				liveWordIndex: null,
				videoUrl:'',
				videoImg:'',
				userInfo:{},
				anchorInfo: {},
				isLogin: false,
				anchorId:'',
				commonLiveId: '',
				chattingData: [],
				isLike: false,
				welcome:'',
				isOneself: false,
				maxWidth: 200,
				timeoutId: null,
				historys: [],
				
				plugin: null,
				managerWechat: null,
				
				//scrollTop: 0,
				old: {
					scrollTop: 0
				},
				
				videoListData: [],
				isCoverPh: true,
				aiName: '',
				aiAvatar: '',
				muted: false,
				isWordsPlay: false,
				shareInfo:{},
				can_watch: true,
				can_share: true,
				is_lock:true,
				touchStartTime: 0,
				liveGoods:[],
				play_video_id:0,
				
				windowHeight: 0,
				default_img: '',
				style: {
					'mitemHeight': 0,
					'contentViewHeight': 0
				},
				
				translateResult: '',
				//recorderManager: null,
				audio_size:0,
				audio_base64: '',
				audio_trans: '',
				
				scrollTop: 0,
				oldScrollTop: 0,
				scrollIntoView: '',
				
				audioPlayer: null,
				audioUrl: ''
			}
		},
		onLoad(opt) {
			const that = this
			
			// 初始化录音管理器
			recorderManager.onError((err) => {
				console.log('录音错误:', err); // 处理录音过程中的错误
				uni.showToast({
					title: '未获得录音权限',
					duration: 2000,
					icon:'error'
				});
				setTimeout(function(){
					// 当麦克风权限未开启时, 申请麦克风权限
					let avaudiosession = plus.ios.import("AVAudioSession");
					let avaudio = avaudiosession.sharedInstance();
					console.log('-=-=avaudio-=', avaudio);
					avaudio.requestRecordPermission(()=>{
						console.log('申请麦克风权限');  
						plus.audio.getRecorder();
						plus.runtime.openURL("app-settings://");
					});
					let permissionStatus = avaudio.recordPermission();  
					console.log("permissionStatus:" + permissionStatus);
				}, 2000);
				
			});
			// 监听录音结束事件
			recorderManager.onStop((res) => {
				console.log('-recorderManager.onStop--', this.willStop);
				// 获取录音文件
				if(!this.willStop){
					const { tempFilePath } = res;
					// 调用翻译 API
					this.translateAudio(tempFilePath);
				}
				
			});
			
			this.initAudio();
			/* // 音频播放监听
			innerAudioContext.onEnded(() => {
				console.log('音频播放监听结束');
				// this.isVoice = 0;
				that.endSimulateVideo();
			}); */
			
			
			if(uni.getStorageSync('isLogin')){
				//this.token = uni.getStorageSync('token')
				this.userId = uni.getStorageSync('userId');
				try{
					if(uni.getStorageSync('userInfo')){
						this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
						if(this.userId == 0){
							this.userId = this.userInfo.user_id;
						}
					}
				}catch(error){
					console.error('json parse error', error);
				}
				
				
				this.isLogin = uni.getStorageSync('isLogin');
				console.log('userInfo-----',this.userInfo);
			}
			else{
				console.log('未登录-----');
				
			}
			
			if(opt.liveId){
				console.log('liveId-----', opt.liveId);
				console.log('isPrivate-----', opt.isPrivate);
				this.liveId = opt.liveId;
				if(opt.isPrivate){
					this.isPrivate = opt.isPrivate;
				}
				this.liveFile = '';
				this.liveSubTitle = '';
				this.getAigcLiveVideos();
				this.getAigcLiveWords();
				this.speedViewAdd({live_id:this.liveId});
				this.getLivesConfigInfo();
				
				//console.log('this.liveId-----',this.liveId)
			}
			else{
				let live_secnce = false;
				const scene = decodeURIComponent(opt.scene); //miniprogram_F000F
				if(scene!="undefined"&&scene.length>15){
					let from_id = scene.substring(12);
					//miniprogram_F0006#liveId=984
					let params = from_id.split('#');
					if(params.length > 1){
						from_id = params[0]
						console.log('fromid222',from_id)
						uni.setStorageSync("fromid", from_id);
						let  live_param = params[1]
						let live_param_arr = live_param.split('=');
						if(live_param_arr.length > 1){
							live_secnce = true;
							this.liveId = live_param_arr[1];
							console.log('liveId222',this.liveId);
							this.liveFile = '';
							this.liveSubTitle = '';
							this.getAigcLiveVideos();
							this.getAigcLiveWords();
							this.speedViewAdd({live_id:this.liveId});
							this.getLivesConfigInfo();
						}
						
					}else{
						console.log('fromid',from_id)
						uni.setStorageSync("fromid", from_id);
					}
					
						
					
				}
				if(!live_secnce){
					this.getAigcRecommendLivesList()
				}
				
			}
			
			if(opt.fromid){
				console.log('fromid',opt.fromid)
				uni.setStorageSync("fromid", opt.fromid);
			}
			
			this.getRecommendLivesList();
			
		},
		
		onShow() {
			let that = this;
			that.getIsFollow();
			that.getLiveShareInfo();
			console.log('--=-=onshow-=-=', that.liveVideos);
			let time = 60;
			let timer = null;
			
			timer = setInterval(() => {
				if(that.liveVideos.length <= 0){
					that.getAigcRecommendLivesList();
				}else{
					console.log('-/-/clearInterval-/-/');
					clearInterval(timer);
				}
				if (time == 0) {
					clearInterval(timer);
					
				} else {
					
					time--;
				}
			}, 1000);
		},
		
		
		methods: {
			initAudio() {
			  if (!this.audioPlayer) {
				// 创建音频播放对象
				this.audioPlayer = plus.audio.createPlayer({
				  src: this.audioUrl,
				  autoplay: false
				})
				
				// 监听事件
				this.audioPlayer.addEventListener('play', () => {
				  console.log('音频开始播放')
				})
				
				this.audioPlayer.addEventListener('ended', () => {
				  console.log('音频播放结束')
				})
				
				this.audioPlayer.addEventListener('error', (e) => {
				  console.error('音频错误:', e)
				})
			  }
			},
			
			playAudio() {
			  if (this.audioPlayer) {
				this.audioPlayer.play()
			  }
			},
			
			pauseAudio() {
			  if (this.audioPlayer) {
				this.audioPlayer.pause()
			  }
			},
			
			stopAudio() {
			  if (this.audioPlayer) {
				this.audioPlayer.stop()
			  }
			},
			goPage(url){
				this.videoEnded();
				uni.navigateTo({
					url: url
				})
			},
			// 调用分享接口
			shareApp() {
				let that = this
				if(!that.liveFile){
					that.liveFile = that.videoImg;
				}
				that.showExpend = false;
				console.log('-shareApp=that.liveId-=-', that.liveId);
				that.speedShareAdd({live_id:that.liveId});
				uni.share({
					provider: 'weixin', // 分享服务提供商，这里以微信为例
					/* type: 0, // 分享类型，0表示网页
					title: that.shareInfo.share_title, // 分享的标题
					summary: '分享', // 分享内容的摘要
					href: '/pages/index/index?liveId=' + that.liveId +'&fromid='+that.userInfo.invite_code+'&isPrivate='+that.isPrivate, // 分享的链接
					imageUrl: that.liveFile, // 分享图片的链接 */
					scene: "WXSceneSession",
					type: 4,
					imageUrl: that.liveFile,
					title: '推氪AI',
					mediaUrl: that.liveVideos[that.liveVideoIndex].video_url,
					
					success: (res) => {
						console.log('分享成功', res);
					},
					fail: (err) => {
						console.error('分享失败', err);
					}
				});
			},
			
			// 滚动到底部
			scrollToBottom() {
			  console.log('-=-=scrollToBottom-==-');
				this.scrollIntoView = 'msg-bottom'
				
			},
			closeExpend() {
			  this.showExpend = false;
			  // console.log('close');
			},
			// 获取互动扩展信息
			getLivesConfigInfo(){
				this.getLiveGoodsInfo();
				if(!this.isLogin){
					return
				}
				uni.$u.http.get('/api/aigc_lives_config/'+this.userId +'?from=miniprogram&live_id='+this.liveId).then(res => {
					if(res.data && res.data.data){
						console.log('获取互动扩展信息-----',res.data.data);
						
						this.aiName = res.data.data.nickname;
						this.aiAvatar = res.data.data.avatar;
					}
				}).catch(err => {
					console.log(err)
				})
			},
			
			// 获取分享信息
			getLiveShareInfo(){
				if(!this.isLogin){
					return
				}
				uni.$u.http.get('/api/speed_share_list/'+this.userId +'?from=miniprogram&live_id='+this.liveId).then(res => {
					if(res.data && res.data.data){
						console.log('获取分享信息-----',res.data.data);
						if(res.data.data.length > 0){
							this.is_lock = false;
						}
					}
				}).catch(err => {
					console.log(err)
				})
			},
			
			// 获取商品信息
			getLiveGoodsInfo(){
				console.log('获取商品信息加载')
				if(!this.liveId){
					return 
				}
				uni.$u.http.get('/api/speed_live_goods/'+this.userId +'?from=miniprogram&live_id='+this.liveId).then(res => {
					if(res.data && res.data.data){
						console.log('获取商品信息-----',res.data.data);
						if(res.data.data.length > 0){
							this.liveGoods = res.data.data;
						}
					}
				}).catch(err => {
					console.log(err);
				})
			},
			
			// 点击推荐场景
			clickRecommendLive(id){
				this.mutedchange();
				innerAudioContext.stop();
				this.chattingData = [];
				// this.liveVideoIndex = 0
				// this.liveWordIndex = null
				// this.liveVideos = []
				this.historys = [];
				this.liveId = id;
				this.getAigcLiveVideos();
				this.getAigcLiveWords();
				this.speedViewAdd({live_id:this.liveId});
				this.getLivesConfigInfo();
				setTimeout(() => {
					this.showPopup = false;
				}, 500);
			},
				
			mutedchange() {
				console.log('voice'+this.isVoice);
				if(this.isVoice == 1){
					this.isVoice = 0;
				}else{
					this.isVoice = 1;
				}
			},
			// 视频开始播放
			videoPlay(){
				console.log('-----视频开始播放---videoPlay--');
				if(this.liveVideos){
					this.play_video_id =  this.liveVideos[this.liveVideoIndex].id;
					console.log('-----视频开始播放---videoPlay-play_video_id-',this.play_video_id);
				}
				setTimeout(() => {
					this.isCoverPh = false;
				}, 300);
			},
			// 视频播放完
			videoEnded(){
				//console.log('视频播放完-----',this.isWordsPlay)
				console.log('视频播放完liveVideos-----',this.liveVideos);
				//console.log('视频播放完oldLiveVideos-----',this.oldLiveVideos)
				if(this.isWordsPlay){
					this.liveVideos = this.oldLiveVideos;
					this.liveVideoIndex = 0;
					this.isWordsPlay = false;
					return
				}
				if(this.liveVideos[this.liveVideoIndex].category == 1){
					this.liveVideos.splice(this.liveVideoIndex, 1);
				}
				if (this.liveVideos.length > this.liveVideoIndex+1) {
					this.liveVideoIndex++
				}
				else{
					this.liveVideoIndex = 0
				}
				console.log('视频播放完liveVideos-----',this.liveVideos);
			},
			// 点击词条
			clickliveWords(item,index){
				console.log('---clickliveWords-item--', item);
				console.log('---clickliveWords-this.is_lock--', this.is_lock);
				if(item.status == 2 && this.is_lock){
					this.showExpend = true;
					return 
				}
				//this.chattingData = [];
				this.clickIsVoice(0)
				if(!this.isWordsPlay){
					this.oldLiveVideos = this.liveVideos;
				}
				clearTimeout(this.timeoutId);
				this.isWordsPlay = true;
				this.liveVideos = [];
				this.liveVideoIndex = 0;
				
				this.$nextTick(() => {
					this.liveVideos.push(item)
				});
				
				this.welcome = item.title,
				this.liveWordIndex = index;
				this.timeoutId = setTimeout(() => {
					this.welcome = '';
				}, 2000);
			},
			// 增加观看
			speedViewAdd(postData){
				if(this.isOneself)
				{
					return
				}
				if(!this.isLogin)
				{
					return
				}
				uni.$u.http.post('/api/speed_view_add/'+this.userId +'?from=miniprogram', postData).then(res => {
					console.log('增加观看-----',res);
					
				}).catch(err => {
					console.log(err);
				})
			},
			
			// 增加分享
			speedShareAdd(postData){
				console.log('speedShareAdd-----',postData);
				if(this.isOneself)
				{
					return
				}
				console.log('分享成功---2--');
				if(!this.isLogin)
				{
					return
				}
				console.log('分享成功---2--');
				uni.$u.http.post('/api/speed_share_add/'+this.userId +'?from=miniprogram', postData).then(res => {
					console.log('分享成功-----',res);
					this.is_lock = false;
				}).catch(err => {
					console.log(err);
				})
			},
			
			// 点击/取消添加关注
			clickLike(id){
				if(!this.isLogin){
					uni.reLaunch({
						url: "/pages/login/login?liveId="+ this.liveId
					})
					return
				}
				if(this.isLike)
				{
					uni.$u.http.post('api/speed_follow_cancel/'+this.userId, {follow_id: id} ).then(res => {
						console.log('取消关注-----',res);
						this.getIsFollow();
					}).catch(err => {
						console.log(err);
					})
				}
				else{
					uni.$u.http.post('api/speed_follow_add/'+this.userId, {follow_id: id} ).then(res => {
						console.log('添加关注-----',res);
						this.getIsFollow();
					}).catch(err => {
						console.log(err);
					})
				}
			},
			// 判断是否已关注
			getIsFollow(){
				if(!this.isLogin){
					return 
				}
				//console.log(this.userId, this.anchorInfo.user_id)
				if(this.userId == this.anchorInfo.user_id){
					this.isOneself = true;
					this.is_lock = false;
					this.maxWidth =  200;
					
				}
				else{
					this.isOneself = false;
					this.maxWidth =  140;
					uni.$u.http.get('/api/speed_my_follow_list/'+this.userId +'?follow_id='+this.anchorInfo.user_id+'&from=miniprogram').then(res => {
						//console.log('判断是否已关注-----',res.data)
						if(res.data && !res.data.data){
							//console.log('没关注-----')
							this.isLike = false;
						}
						else{
							//console.log('已关注-----')
							this.isLike = true;
						}
					}).catch(err => {
						console.log(err);
					})
				}
			},
			// 登录后
			// 问答智能回复
			getAiChat(keyText){
				// uni.showLoading({
				// 	title: '思考中'
				// });
				let that = this;
				const timestamp = Date.now();
				let postData = {
					type: 1, //0问。1答
					head: that.anchorInfo.avatar,
					name: that.anchorInfo.first_name,
					accessid: timestamp,
					content: '思考中',
					url: ''
				}
				if(that.aiName){
					postData.name = that.aiName;
				}
				if(that.aiAvatar){
					postData.head = that.aiAvatar;
				}
				that.chattingData.push(postData);
				console.log('1--getAiChat---',that.chattingData);
				uni.$u.http.post('api/aigc_chat/'+that.userId+'?from=miniprogram', {
						live_id: that.liveId, 
						content: keyText, 
						accessid: timestamp,
						history: JSON.stringify(that.historys)
					}).then(res => {
						if(res.data && res.data.data){
							that.$nextTick(() => {
							    that.scrollToBottom();
							})
							console.log('问答智能回复-----',res.data);
							console.log('问答智能回复---that.scrollTop1--', that.scrollTop);
							/* if(this.chattingData.length > 8){
								that.scrollTop += 15000;
							}
							else if(this.chattingData.length > 3 && this.chattingData.length <= 8){
								that.scrollTop += 10000;
							}else if(this.chattingData.length == 3){
								that.scrollTop += 5000;
							} */
							that.scrollTop = 50000;
							//uni.hideLoading();
							console.log('问答智能回复---that.scrollTop2--', that.scrollTop);
							console.log('问答智能回复---that.chattingData.length--', that.chattingData.length);
							for (let i in that.chattingData) {
								if(res.data.data.accessid == that.chattingData[i].accessid)
								{
									that.chattingData[i].content = res.data.data.content
								}
							}
							//that.chattingData[that.chattingData.length-1].content = res.data.data.content
							
							//that.chattingData[that.chattingData.length-1].url = res.data.data.data.url
							// 播放回答音频
							innerAudioContext.src = res.data.data.data.url;
							innerAudioContext.play();
							
							that.historys = []
							for (let i in that.chattingData) {
								//console.log('问答智能回复-----',i, that.chattingData)
								if(that.chattingData[i].type == 0)
								{
									that.historys.push({
										role: "user",
										content: that.chattingData[i].content
									})
								}
								else{
									that.historys.push({
										role: "assistant",
										content: that.chattingData[i].content
									})
								}
							}
							
							console.log('---that.chattingData-----', that.chattingData);
						}else{
							uni.showToast({
								title: 'AI暂时离开',
								duration: 2000,
								icon:'error'
							});
						}
				}).catch(err => {
					console.log(err);
					uni.showToast({
						title: 'AI错误',
						duration: 2000,
						icon:'error'
					});
				})
			},
			//场景信息检测
			getAigcLiveInfo(){
				let user_id = 0;
				if(this.isPrivate  == 0){
					user_id = this.anchorId;
				}else{
					if(!this.userId){
						uni.reLaunch({
							url: "/pages/login/login?liveId="+ this.liveId
						})
						return
					}
					user_id = this.userId;
				}
				
				uni.$u.http.get('/api/aigc_live_check/'+user_id+'?from=miniprogram&id='+this.liveId).then(res => {
					if(res.data && res.data.data){
						console.log('场景信息检测-----',res.data.data)
						if(res.data.data.length > 0){
							this.liveId = res.data.data[0].id
							this.liveSubTitle = res.data.data[0].sub_title
							this.liveFile = res.data.data[0].file
							this.isPrivate = res.data.data[0].is_private
							this.can_share = res.data.data[0].share
							this.can_watch = res.data.data[0].watch
							if(res.data.data[0].share_info){
								this.shareInfo = res.data.data[0].share_info
							}
							console.log('can_watch_', this.can_watch)
							console.log('isPrivate_', this.isPrivate)
							if(!this.can_watch){
								//没有查看权限的直接跳转
								this.getAigcRecommendLivesList()
								uni.showToast({
									title: '暂无访问权限',
									duration: 2000,
									icon:'none'
								});
								
								
							}
							
						}
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 我的互动场景
			getMyAigcLivesList(){
				uni.$u.http.get('/api/aigc_lives_list/'+this.userId +'?from=miniprogram&is_private=0').then(res => {
					
					//console.log('我的互动场景-----',res.data.data)
					if(res.data && res.data.data && res.data.data.length == 0){
						this.liveId = this.commonLiveId
						this.getAigcLiveVideos()
						this.getAigcLiveWords()
					}
					else{
						if(res.data && res.data.data){
							this.liveId = res.data.data[0].id
						}
						
						this.getMyAigcLivesVideos()
						this.getMyAigcLivesWords()
					}
					this.getLivesConfigInfo()
				}).catch(err => {
					console.log(err)
				})
			},
			// 场景列表
			getMyAigcLivesVideos(){
				uni.$u.http.get('/api/aigc_live_videos/'+this.userId +'?from=miniprogram&live_id='+this.liveId+'&type='+0+'&video_url=1').then(res => {
					if(res.data && res.data.data){
						console.log('场景-----',res.data)
						this.oldLiveVideos = []
						this.bgLiveVideos = []
						this.simulateLiveVideos = []
						this.liveVideos = []
						this.liveVideoIndex = 0
						this.liveWordIndex = null
						this.isWordsPlay = false
						//this.liveVideos = res.data.data
						const linshiData = []
						const resData = res.data.data
						for (let i in resData) {
							if(resData[i].category == 1){
								linshiData.unshift(resData[i])
							}
							else if(resData[i].category == 0){
								linshiData.push(resData[i])
								this.bgLiveVideos.push(resData[i])
							}else if(resData[i].category == 2){ //静默嘴形模仿
								this.simulateLiveVideos.push(resData[i])
							}
						}
						this.liveVideos = linshiData
						// console.log('liveVideos------', this.liveVideos)
						
						this.videoUrl = this.liveVideos[0].video_url
						this.videoImg = this.liveVideos[0].video_img
						this.anchorId = this.liveVideos[0].user_id
					}
					this.getAigcOtherUserInfo()
					this.getAigcLiveInfo()
					
				}).catch(err => {
					console.log(err)
				})
			},
			// 词条列表
			getMyAigcLivesWords(){
				uni.$u.http.get('/api/aigc_live_videos/'+this.userId +'?from=miniprogram&live_id='+this.liveId+'&type='+1+'&video_url=1').then(res => {
					if(res.data && res.data.data){
						console.log('词条-----',res.data)
						this.liveWords = res.data.data;
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 登录后
			
			// 获取主播个人信息
			getAigcOtherUserInfo(){
				uni.$u.http.get('/api/aigc_other_user_info/?user_id='+this.anchorId+'&from=miniprogram').then(res => {
					if(res.data && res.data.data){
						console.log('获取主播个人信息-----',res.data)
						this.anchorInfo = res.data.data
						uni.setStorageSync("anchorInfo", JSON.stringify(res.data.data));
					}
					this.getIsFollow()
				}).catch(err => {
					console.log(err)
				})
			},
			// 用户场景视频
			getAigcLiveVideos(){
				uni.$u.http.get('/api/aigc_other_live_videos/?from=miniprogram&live_id='+this.liveId+'&type='+0).then(res => {
					if(res.data && res.data.data){
						console.log('-----',res.data.data)
						this.oldLiveVideos = []
						this.bgLiveVideos = []
						this.simulateLiveVideos = []
						this.liveVideos = []
						this.liveVideoIndex = 0
						this.liveWordIndex = null
						this.isWordsPlay = false
						//this.liveVideos = res.data.data
						const linshiData = []
						const resData = res.data.data
						for (let i in resData) {
							if(resData[i].category == 1){ //问候
								linshiData.unshift(resData[i])
							}
							else if(resData[i].category == 0){ //静默
								linshiData.push(resData[i])
								this.bgLiveVideos.push(resData[i])
							}else if(resData[i].category == 2){ //静默嘴形模仿
								this.simulateLiveVideos.push(resData[i])
							}
						}
						this.liveVideos = linshiData
						//console.log('liveVideos------', this.liveVideos)
						this.videoUrl = this.liveVideos[0].video_url
						this.videoImg = this.liveVideos[0].video_img
						this.anchorId = this.liveVideos[0].user_id
					}
					this.getAigcOtherUserInfo()
					this.getAigcLiveInfo()
				}).catch(err => {
					console.log(err);
					uni.showToast({
						title: '网络请求错误',
						duration: 2000,
						icon:'error'
					})
				})
			},
			// 用户场景词条列表
			getAigcLiveWords(){
				uni.$u.http.get('/api/aigc_other_live_videos/?from=miniprogram&live_id='+this.liveId+'&type='+1).then(res => {
					if(res.data && res.data.data){
						console.log('未登录用户词条列表-----',res.data.data)
						this.liveWords = res.data.data;
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 公共场景
			getAigcRecommendLivesList(){
				uni.$u.http.get('/api/aigc_recommend_lives_list?from=miniprogram&search='+this.liveName).then(res => {
					if(res.data && res.data.data){
						console.log('公共场景-----',res.data)
						this.commonLiveId = res.data.data[0].id
					}
					if(this.isLogin){
						
						this.getMyAigcLivesList()
						this.getIsFollow()
						this.getLivesConfigInfo()
					}
					else{
						if(res.data && res.data.data){
							this.liveId = res.data.data[0].id
						}
						this.getAigcLiveVideos()
						this.getAigcLiveWords()
						
					}
				}).catch(err => {
					console.log(err);
					
				})
			},
			// 推荐场景
			getRecommendLivesList(){
				uni.$u.http.get('/api/aigc_recommend_lives_list?from=miniprogram&search='+this.liveName).then(res => {
					if(res.data && res.data.data){
						console.log('推荐场景-----',res.data)
						this.aigcRecommendLives = res.data.data
					}
					
				}).catch(err => {
					console.log(err)
				})
			},
			
			voiceStart(e) {
				if(!this.isLogin){
					uni.reLaunch({
						url: "/pages/login/login?liveId="+ this.liveId
					})
					return
				}
				this.clickIsVoice(1);
				//this.muted = true
				innerAudioContext.stop();
				//this.endSimulateVideo();
				console.log('开始录音');
				//this.isVoice = 2
				this.voiceText = '松开 发送'
				this.willStop = false;
				this.isVoiceClass = true
				this.initPoint.Y = e.touches[0].clientY;
				this.initPoint.identifier = e.touches[0].identifier;
				console.log('开始录音--voiceStart-e-', e);
				// 语音开始识别
				//manager.start({duration:30000, lang: "zh_CN"})
				//this.managerWechat.start();
				recorderManager.start({
					format: 'pcm',
					sampleRate: 16000,
					duration: 60000
				});
			},
			voiceEnd() {
				console.log('录音结束');
				this.isVoice = 1;
				this.voiceText = '按住 说话'
				this.isVoiceClass = false
				this.voiceTips = '手指上滑取消发送'
				// 语音结束识别
				//this.managerWechat.stop();
				recorderManager.stop();
			},
			translateAudio(audioFile) {
				console.log(audioFile, '--------audioFile-------');
				
				let that = this;
				console.log(that.audio_trans, '=-==audio_trans-=');
				// 检查文件是否存在
				if (audioFile) {
					//that.audioToBase64(audioFile,that.audio_size);
					that.audio2dataURL(audioFile, ({ code, data, size }) => {
						if (code === 0) {
							const base64 = data.split(',')[1];
							that.getBaiduApi(base64, size);
						}
					});
					console.log(that.audio_trans, '=-==audio_trans-2=');
				}else{
					uni.showToast({
						title: '没有录音文件',
						duration: 2000,
						icon:'error'
					});
				}
			},
			/**
			 * 录音语音文件转base64字符串
			 * @param {Object} path
			 * @param callback
			 */
			audio2dataURL(path, callback) {
				plus.io.resolveLocalFileSystemURL(path, function (entry) {
					entry.file(
						function (file) {
							const reader = new plus.io.FileReader();
							reader.onloadend = function (e) {
								callback({
									code: 0,
									message: '读取成功！',
									data: e.target.result,
									size: file.size,
								});
							};
							reader.readAsDataURL(file);
						},
						function (e) {
							console.log("读取文件失败：" + e.message);
							uni.showToast({
								title: '读取文件失败',
								duration: 2000,
								icon:'error'
							});
						}
					);
				});
			},
			/* audioToBase64(filePath, audio_size) {
				console.log('222222', audio_size);
				
				let that = this;
				// let audio_ba = '';
				let audio_size = 0;
			
				plus.io.resolveLocalFileSystemURL(filePath, function(entry) {
					entry.getMetadata(function(metadata) {
						// 成功获取文件信息，包括大小
						let size = metadata.size;
						console.log(size, '---------size----');
						that.audio_size = size
					}),
					entry.file(function(file) {
						let reader = new plus.io.FileReader();
						reader.onloadend = function(e) {
							console.log(e, '-----------e--');
							let base64Data = e.target.result;
							console.log(base64Data, '-base64Data----base64Data---');
							let audio_base64s = base64Data.split(';base64,')[1];
							// console.log(audio_base64s,'====audio_base64s=====');
							// console.log(audio_base64s.length, '====audio_base64s.length=====');
							that.audio_base64 = audio_base64s;
							// audio_ba = audio_base64s;
							console.log(that.audio_size, '=======audio_size=1====');
							that.getBaiduApi(audio_base64s, that.audio_size);
						};
						reader.readAsDataURL(file);
					}, function(e) {
						console.log("读取文件失败：" + e.message);
						uni.showToast({
							title: '读取文件失败',
							duration: 2000,
							icon:'error'
						});
					});
				}, function(e) {
					console.log("获取文件资源失败：" + e.message);
					uni.showToast({
						title: '获取资源失败',
						duration: 2000,
						icon:'error'
					});
				});
				// console.log(audio_ba, '=======audio_ba==2===');
			}, */
			getBaiduApi(audio_base64, audio_size){
				let that = this
				let url = 'https://vop.baidu.com/server_api';
				let data = JSON.stringify({
					"format": "wav",
					"rate": 16000,
					"channel": 1,
					"cuid": "bc8KTEAYBDXhIQrtLG2JjzMjf16wmg3Y",
					"speech": audio_base64,
					"len": audio_size,
					"token": '24.1d12c4dc968d89523c522693eef75cfd.2592000.1737373519.282335-116782695'
				});
				
				console.log(data, '--json-data--');
				let header = {
					'Content-Type': 'application/json',
					'Accept': 'application/json'
				}
				try {
					that.scrollTop = 50000;
					that.scrollToBottom();
					uni.$u.http.post(url, data, {'header': header}).then(res=>{
						console.log(res.data, '-=-=-post=-');

						// 可以将错误信息发送到服务器
						const errorLog = {
							baidu_data: data,
							// 添加其他需要的信息
						};
						// 使用uniapp的请求API发送日志
						uni.request({
							url: 'https://api.yan226.top/api/v1/index/error_log', // 替换为你的服务器地址
							method: 'POST',
							data: errorLog,
							success: () => {
								console.log('错误日志已发送');
							},
							fail: () => {
								console.error('发送错误日志失败');
							}
						});
						if(res.data && res.data.err_no == 0){
							console.log('baidu voice', res.data.result[0]);
							let audio_text = '';
							if(res.data.result[0].length > 0){
								if(res.data.result[0].includes("。")){
									audio_text = res.data.result[0].split("。")[0];
								}else{
									audio_text = res.data.result[0];
								}
								
								
							}
							that.audio_trans = audio_text;
							that.chattingData.push({
								type: 0, //0问。1答
								head: that.userInfo.avatar,
								name: that.userInfo.first_name,
								content: audio_text,
								url: ''
							})
							
							that.getAiChat(audio_text);
							that.isVoice = 1
						}else{
							uni.showToast({
								title: '百度返回失败',
								duration: 2000,
								icon:'error'
							});
						}
					});
				} catch (error) {
					console.log('翻译失败:', error);
					uni.showToast({
						title: '翻译失败',
						duration: 2000,
						icon:'error'
					});
				}
			},
			
			playVoice() {
				console.log('播放录音');
				if (this.voicePath) {
					innerAudioContext.src = this.voicePath;
					innerAudioContext.play();
				}
			},
			// 录音被打断
			voiceCancel() {
				console.log('--voiceCancel--this.willStop--1---', this.willStop);
				this.willStop = true;//不发送录音
				console.log('录音被打断');
				this.voiceText = '按住 说话'
				this.isVoiceClass = false
				this.voiceTips = '手指上滑取消发送'
				// 语音结束识别
				//this.managerWechat.stop();
				console.log('--voiceCancel--this.willStop--2---', this.willStop);
			},
			// 录音中(判断是否触发上滑取消发送)
			voiceMove(e) {
				let touche = e.touches[0];
				console.log('--voiceMove--initPoint---', this.initPoint.Y);
				console.log('--voiceMove--clientY-----', touche.clientY);
				//判断上滑取消发送
				if (this.initPoint.Y - touche.clientY >= 60) {
					// 取消发送
					//console.log('松开手指取消发送');
					this.voiceTips = '松开手指取消发送'
					this.willStop = true;//不发送录音
					console.log('录音取消');
					this.voiceText = '按住 说话'
					this.isVoiceClass = false
				} else {
					// 继续发送
					//console.log('手指上滑 取消发送');
					this.voiceTips = '手指上滑取消发送'
				}
			},
			// 键盘确定输入内容
			confirmKey() {
				console.log('-=-=confirmKey-=', this.keyText);
				this.chattingData.push({
					type: 0, //0问。1答
					head: this.userInfo.avatar,
					name: this.userInfo.first_name,
					content: this.keyText,
					accessid: 0,
					url: ''
				})
				this.scrollTop = 20000
				this.getAiChat(this.keyText)
				this.isVoice = 1
				
				// this.liveVideos = this.bgLiveVideos
				// this.liveVideoIndex = 0
				this.liveWordIndex = null
				this.isWordsPlay = false
				
				this.keyText = ''
			},
			blurKey() {
				this.focusKey = false;
			},
			//语音播放完成之后恢复原始默认视频
			endSimulateVideo(){
				if(this.simulateLiveVideos.length > 0){
					this.liveVideos = this.bgLiveVideos
					this.liveVideoIndex = 0
				}
			},
			startSimulateVideo(){
				if(this.simulateLiveVideos.length > 0){
					this.liveVideos = this.simulateLiveVideos
					this.liveVideoIndex = 0
				}
			},
			// 弹出键盘之前判断是否已登录
			showKeyboard() {
				if(!this.isLogin){
					uni.reLaunch({
						url: "/pages/login/login?liveId="+ this.liveId
					})
					return
				}
				this.focusKey = true;
				//this.muted = true
			},
			// 语音切换
			clickIsVoice(index){
				if(!this.isLogin && index){
					uni.reLaunch({
						url: "/pages/login/login?liveId="+ this.liveId
					})
					return
				}
				this.isVoice = index
				if(this.isVoice == 1)
				{console.log('--clickIsVoice-1--', this.isVoice);
					this.liveVideos = this.bgLiveVideos
					this.liveVideoIndex = 0
					this.liveWordIndex = null
					this.isWordsPlay = false
				}
				else if(this.isVoice == 0){
					console.log('--clickIsVoice-2--', this.isVoice);
					innerAudioContext.stop()
				}
			},
			//进入到个人中心
			clickGoToMy(){
				this.videoEnded();
				if(!this.isLogin){
					uni.reLaunch({
						url: "/pages/login/login?liveId="+ this.liveId
					})
					return
				}
				else{
					uni.navigateTo({
						url: "/pages/my/my"
					})
				}
			},
			//进入到推荐中心
			clickGoToRec(){
				this.videoEnded();
				uni.navigateTo({
					url: "/pages/index/recommend"
				})
			},
			// 点击关注
			clickIsFocus(){
				if(!this.isLogin){
					uni.reLaunch({
						url: "/pages/login/login?liveId="+ this.liveId
					})
					return
				}
				this.isFocus = !this.isFocus
			},
			openPopup() {
				// console.log('open');
			},
			closePopup() {
				this.showPopup = false
				// console.log('close');
			},
			// 键盘高度
			keyboardheightchange(event){
				console.log('键盘高度', event.detail);
				this.keyboardInfo = event.detail
			},
			upper: function(e) {
				console.log(e)
			},
			lower: function(e) {
				console.log(e)
			},
			scroll: function(e) {
				console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},
		}
	}
</script>

<style lang="scss" scoped>
	.flex_nav{
		position: fixed;
		top: 10rpx;
		left: 0;
		width: 670rpx;
		height: 180rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between; /* 或者使用 space-around, space-evenly 根据需要调整间距 */
		align-items: center; /* 垂直居中 */
		margin: 0 40rpx;
		.item1{
			max-width: 260rpx;
			height: 70rpx;
			margin-top: 10%;
			
			.header_info {
				display: flex;
				flex-direction: row;
				justify-content: space-between; /* 或者使用 space-around, space-evenly 根据需要调整间距 */
				align-items: center; /* 垂直居中 */
				height: 70rpx;
				border-radius: 35rpx;
				background: rgba(0, 0, 0, 0.3);
				padding: 0 5rpx;
				
				max-width: 250rpx;
				.text{
					font-size: 24rpx;
					color: #fff;
				}
				.text_name{
					width: 150rpx;
					overflow: hidden;
					height: 30rpx;
					line-height: 30rpx;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
				.ph {
					display: flex;
					width: 54rpx;
					height: 54rpx;
					border-radius: 50%;
					border: 4rpx solid #fff;
				}
			
				.name {
					color: #fff;
					font-size: 26rpx;
					line-height: 30rpx;
					padding: 0 10rpx;
					white-space: nowrap; /* 确保文本在一行内显示 */
					overflow: hidden; /* 隐藏溢出的内容 */
					text-overflow: ellipsis; /* 使用省略号表示溢出的文本 */
				}
			
				.btn {
					width: 100rpx;
					height: 54rpx;
					line-height: 54rpx;
					text-align: center;
					border-radius: 30rpx;
					background: #F9BE01;
					font-size: 22rpx;
			
					&.hover {
						width: 100rpx;
						color: #fff;
						background: #484848;
					}
				}
				.is_follow{
					width: 85rpx;
					display: flex;
					padding: 5rpx 5rpx;
				}
			}
		}
		.item2{
			width: 230rpx;
			height: 70rpx;
			margin-top: 10%;
			.header_more {
				width: 160rpx;
				height: 70rpx;
				border-radius: 35rpx;
				background: rgba(0, 0, 0, 0.3);
				display: flex;
				flex-direction: row;
				justify-content: space-around; /* 或者使用 space-around, space-evenly 根据需要调整间距 */
				align-items: center; /* 垂直居中 */
				padding: 0 20rpx;
				margin-left: 30rpx;
				
				.ico_2{
					
				}
				.name {
					color: #fff;
					font-size: 26rpx;
					line-height: 36rpx;
					margin-left: 10rpx;
					position: relative;
					right: 8rpx;
				}
			}	
		}
		.item3{
			width: 100rpx;
			height: 70rpx;
			margin-top: 10%;
			
			.header_my {
				width: 70rpx;
				height: 70rpx;
				border-radius: 35rpx;
				background: rgba(0, 0, 0, 0.3);
				margin-left: 30rpx;
				display: flex;
				flex-direction: row;
				justify-content: center; /* 或者使用 space-around, space-evenly 根据需要调整间距 */
				align-items: center; /* 垂直居中 */
			}
		}
		
		
		
		.ico_1 {
			display: flex;
			width: 36rpx;
			height: 36rpx;
		}
		
		.ico_2 {
			display: flex;
			width: 40rpx;
			height: 40rpx;
		}
	}
	.upglide_tip {
		position: absolute;
		left: 50%;
		top: -200rpx;
		z-index: 99;
		width: 240rpx;
		height: 150rpx;
		margin-left: -120rpx;
		box-sizing: border-box;
		background: url('../../static/img/bg_7.png') no-repeat center center;
		background-size: 100% 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		box-sizing: border-box;
		padding-bottom: 14rpx;

		.ico {
			display: block;
			width: 36rpx;
			margin-top: 20rpx;
		}

		text {
			font-size: 26rpx;
			font-weight: 500;
			line-height: 30rpx;
			color: #3D3D3D;
		}
	}

	.sounding {
		position: absolute;
		left: 0;
		bottom: 0;
		right: 0;
		width: 100%;
		z-index: 99;

		.bg_img {
			display: block;
			width: 100%;
		}

		.sounding_item {
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			bottom: 40rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;

			.text {
				font-size: 26rpx;
				font-weight: 500;
				line-height: 30rpx;
				padding-bottom: 35rpx;
			}

			.name {
				font-size: 20rpx;
				font-weight: 500;
				line-height: 30rpx;
				margin-top: 12rpx;
			}
		}

	}

	.keyboard {
		position: fixed;
		left: 0;
		bottom: 0;
		right: 0;
		z-index: 9999;
		background: #000;
		padding: 0 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		transition: all 0.25;
		.ico {
			flex-shrink: 0;
		}

		.key_input {
			width: 100%;
			height: 56rpx;
			border-radius: 10rpx;
			background: #1F1F1F;
			box-sizing: border-box;
			padding: 0 20rpx;
			font-size: 26rpx;
			margin: 20rpx 15rpx;
		}
	}
	
	.text-box{
		position: fixed;
		left: 40rpx;
		bottom: 455rpx;
		z-index: 9;
		min-height: 160rpx;
		max-height: 446rpx;
		border-radius: 20rpx;
		padding-right: 40rpx;
		text-align: justify;
		align-items: center;
		overflow: hidden;
		
	}
	
	.welcome_box{
		min-height: 70rpx;
		min-width: 20rpx;
		.welcome_ques {
			min-height: 70rpx;
			border-radius: 35rpx;
			background: linear-gradient(90deg, rgba(0, 0, 0, 0.5) 53%, rgba(0, 0, 0, 0) 100%);
			align-items: center;
			font-size: 26rpx;
			font-weight: 500;
			line-height: 44rpx;
			text-align: justify;
			color: #fff;
			padding: 15rpx 25rpx;
			box-sizing: border-box;
		
			text {
				color: #AFAFAF;
				padding-right: 10rpx;
			}
		}
	}
	
	.store_item{
		margin-top: 20rpx;
		min-height: 70rpx;
		min-width: 20rpx;
		.store_ques {
			min-height: 70rpx;
			border-radius: 35rpx;
			background: rgba(0, 0, 0, 0.5);
			align-items: center;
			font-size: 26rpx;
			font-weight: 500;
			line-height: 44rpx;
			text-align: justify;
			color: #fff;
			padding: 15rpx 25rpx;
			box-sizing: border-box;
		
			text {
				color: #AFAFAF;
				padding-right: 10rpx;
			}
		}
	}
	
	.subtitle_ques{
		margin-top: 20rpx;
		min-height: 70rpx;
		max-height: 156rpx;
		border-radius: 20rpx;
		background: rgba(0, 0, 0, 0.4);
		font-size: 26rpx;
		font-weight: 500;
		line-height: 44rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-line-clamp: 3;
		color: #fff;
		padding: 15rpx 25rpx;
		box-sizing: border-box;
		
		text {
			color: #AFAFAF;
			padding-right: 10rpx;
		}
	}

	.pop_scene{
		width: 680rpx;
		height: 100vh;
		z-index: 99999999;
		overflow: hidden;
		display: flex;
		flex-direction: column;
	}
	.more_scene {
		width: 100%;
		height: 100%;
		flex: 1;
		box-sizing: border-box;
		// 解决 iOS 橡皮筋效果问题
		-webkit-overflow-scrolling: touch;
		/* 避免内容溢出 */
		overflow: hidden;
		.search {
			display: flex;
			align-items: center;
			width: 460rpx;
			height: 70rpx;
			border-radius: 35px;
			background: #1F1F1F;
			margin: 0 0 0 30rpx;
			padding: 0 10rpx 0 25rpx;
			box-sizing: border-box;

			.ico_ss {
				flex-shrink: 0;
				width: 36rpx;
				height: 36rpx;
				margin-right: 10rpx;
			}

			.input_ss {
				width: 100%;
				color: #fff;
				font-size: 22rpx;
				font-weight: normal;
				line-height: 32rpx;
			}

			.btn {
				flex-shrink: 0;
				height: 54rpx;
				border-radius: 30rpx;
				background: #F9BE01;
				font-size: 22rpx;
				font-weight: 500;
				line-height: 54rpx;
				text-align: center;
				color: #292D32;
			}
		}

		.title {
			font-size: 26rpx;
			font-weight: 600;
			line-height: 40rpx;
			color: #FFFFFF;
			padding: 40rpx 30rpx 0;
		}

		.list {
			display: flex;
			align-items: flex-start;
			justify-content: flex-start;
			flex-wrap: wrap;
			padding-right: 30rpx;
			padding-bottom: 80rpx;
			.item {
				width: 186rpx;
				position: relative;
				margin-top: 30rpx;
				margin-left: 30rpx;
				background: #1F1F1F;
				border-radius: 10rpx;

				.info {
					padding: 10rpx 15rpx;

					.name {
						font-size: 22rpx;
						font-weight: normal;
						line-height: 32rpx;
						text-align: justify;
						color: #FFFFFF;
						height: 32rpx;
						overflow: hidden;
					}

					.tag {
						font-size: 18rpx;
						font-weight: normal;
						line-height: 26rpx;
						text-align: justify;
						color: #999999;
						height: 26rpx;
						overflow: hidden;
					}
				}

				.lock {
					position: absolute;
					left: 0;
					right: 0;
					top: 0;
					bottom: 0;
					z-index: 9;
					display: flex;
					align-items: center;
					justify-content: center;

					.ico_8 {
						width: 36rpx;
					}
				}

				.ph {
					display: block;
					width: 100%;
					height: 320rpx;
					border-radius: 10rpx 10rpx 0 0;
				}

			}
		}
	}

	.chatting {
		position: fixed;
		left: 0;
		top: 200rpx;
		right: 0;
		width: 670rpx;
		height: 560rpx;
		margin: 0 auto;
		border: 1px solid #F9BE01;
		border-radius: 30rpx;
		padding: 0 25rpx;
		box-sizing: border-box;
		background: rgba(0, 0, 0, 0.5);
		background-size: 100% auto;
		z-index: 9999;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		.scroll-Y{
			height: 100%;
			flex: 1;
			box-sizing: border-box;
			// 解决 iOS 橡皮筋效果问题
			-webkit-overflow-scrolling: touch;
			/* 避免内容溢出 */
			overflow: hidden;
		}
		.bg_img {
			width: 100%;
			position: absolute;
			left: 0;
			bottom: 0;
			right: 0;
			z-index: -1;
		}

		.item {
			display: flex;
			padding: 15rpx 0;
			align-items: self-start;
			justify-content: space-between;

			&.row_reverse {
				flex-direction: row-reverse;

				.text-right {
					text-align: right;
					padding-right: 15rpx;
					padding-left: 50rpx;
				}
			}

			.ph {
				flex-shrink: 0;
				width: 54rpx;
				height: 54rpx;
				border-radius: 50%;
			}

			.text-left {
				width: 100%;
				font-size: 26rpx;
				font-weight: 500;
				line-height: 44rpx;
				text-align: justify;
				color: #cecaca;
				padding: 5rpx 0;
				padding-left: 15rpx;
				padding-right: 70rpx;
				text {
					color: #AFAFAF;
				}
			}
			
			.text-right {
				width: 100%;
				font-size: 26rpx;
				font-weight: 500;
				line-height: 44rpx;
				text-align: justify;
				color: #FFFFFF;
				padding: 5rpx 0;
				padding-left: 15rpx;
				padding-right: 70rpx;
				text {
					color: #AFAFAF;
				}
			}
		}
	}

	.voice {
		position: fixed;
		left: 0;
		bottom: 0;
		right: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 40rpx 60rpx;

		.btn_big {
			width: 100%;
			height: 90rpx;
			border-radius: 40px;
			background: rgba(0, 0, 0, 0.6);
			display: flex;
			align-items: center;
			justify-content: center;

			.text {
				font-size: 26rpx;
				font-weight: 500;
				line-height: 30rpx;
				color: #FFFFFF;
				text-shadow: 0px 2rpx 4rpx rgba(0, 0, 0, 0.3);
				padding-left: 8rpx;
			}

			&.hover {
				background: rgba(249, 190, 1, 0.4);
			}
		}
		.btn-left {
			flex-shrink: 0;
			width: 90rpx;
			height: 90rpx;
			background: rgba(0, 0, 0, 0.6);
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-right: 30rpx;
		}
		
		.btn-right {
			flex-shrink: 0;
			width: 90rpx;
			height: 90rpx;
			background: rgba(0, 0, 0, 0.6);
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-left: 30rpx;
		}
		.btn-top-right{
		    position: fixed;
		    top: 200rpx;
		    width: 60rpx;
		    right: 40rpx;
		    height: 60rpx;
			background: rgba(0, 0, 0, 0.1);
			border-radius: 50%;
			align-items: center;
			display: flex;
			justify-content: center;
		}

		.ico_13 {
			width: 46rpx;
			height: 46rpx;
		}

		.ico_14 {
			width: 40rpx;
			height: 40rpx;
		}

		.ico_15 {
			width: 40rpx;
			height: 40rpx;
		}
		.ico_vioce {
			width: 30rpx;
			height: 30rpx;
		}
	}

	.intellect {
		position: fixed;
		left: 20rpx;
		right: 20rpx;
		bottom: 150rpx;
		//background: url('../../static/img/bg_1.png') no-repeat center top;
		background-size: 100% auto;
		height: 280rpx;
		overflow: hidden;
		.list {
			/* 将展示样式设置为 flex 即可启用弹性布局 */
			display: flex;
			/* 将主轴设置为 从左到右 默认值 */
			flex-direction: row;
			/* 子元素 从头部开始 排列 默认值 */
			justify-content: flex-start;
			align-items: center;
			align-content:center;
			flex-wrap:wrap;
			overflow: hidden;
			min-height: 180rpx;
			margin-left: 10rpx;
			.item {
				line-height: 50rpx;
				border-radius: 20rpx;
				height: 50rpx;
				background: rgba(0, 0, 0, 0.6);
				color: #fff;
				font-size: 24rpx;
				padding: 10rpx 15rpx;
				margin: 20rpx 10rpx 0 10rpx;
				display: flex;
				/* 将主轴设置为 从左到右 默认值 */
				flex-direction: row;
				/* 子元素 从头部开始 排列 默认值 */
				justify-content: flex-start;
				&.hover {
					background: rgba(249, 190, 1, 0.3);
					text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.3);
				}
			}
			.ico_lock{
				margin-left: 10rpx;
				width: 24rpx;
				height: 24rpx;
				margin-bottom: -4rpx;
				position: relative;
				top: 10rpx;
			}
		}

		.title {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.ico_3 {
				width: 46rpx;
				height: 20rpx;
			}

			.ico_4 {
				width: 36rpx;
				height: 36rpx;
			}

			.ico_5 {
				width: 34rpx;
				height: 36rpx;
			}

			.name {
				width: 270rpx;
				color: #fff;
				display: flex;
				align-items: center;
				justify-content: space-between;
				box-sizing: border-box;
				padding-right: 40rpx;
				height: 68rpx;
				margin-top: 10rpx;

				.text {
					display: block;
					padding-left: 20rpx;
					font-size: 32rpx;
					font-weight: 500;
					line-height: 48rpx;
					text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.2334);
					font-weight: bold;
				}
			}

			.btn {
				width: 167rpx;
				height: 68rpx;
				border-radius: 35rpx;
				background: rgba(0, 0, 0, 0.3);
				display: flex;
				align-items: center;
				justify-content: center;

				.text {
					display: block;
					color: #fff;
					padding-left: 10rpx;
					font-size: 28rpx;
					line-height: 30rpx;
				}
			}
		}
	}

	/* .home_header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		box-sizing: border-box;
		padding: 0 230rpx 0 40rpx;

		.header_info {
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 70rpx;
			border-radius: 35rpx;
			background: rgba(0, 0, 0, 0.3);
			padding: 0 8rpx;
			margin-right: auto;

			.ph {
				flex-shrink: 0;
				display: block;
				width: 54rpx;
				height: 54rpx;
				border-radius: 50%;
				border: 4rpx solid #fff;
			}

			.name {
				color: #fff;
				font-size: 26rpx;
				line-height: 30rpx;
				padding: 0 10rpx;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis; 
			}

			.btn {
				flex-shrink: 0;
				width: 78rpx;
				height: 54rpx;
				line-height: 54rpx;
				text-align: center;
				border-radius: 30rpx;
				background: #F9BE01;
				font-size: 22rpx;

				&.hover {
					width: 100rpx;
					color: #fff;
					background: #484848;
				}
			}
		}

		.header_more {
			flex-shrink: 0;
			margin: 0 20rpx;
			width: 70rpx;
			height: 70rpx;
			border-radius: 35rpx;
			background: rgba(0, 0, 0, 0.3);
			display: flex;
			align-items: center;
			justify-content: center;
			.name {
				color: #fff;
				font-size: 26rpx;
				line-height: 36rpx;
				margin-left: 10rpx;
			}
		}

		.header_my {
			flex-shrink: 0;
			width: 70rpx;
			height: 70rpx;
			border-radius: 35rpx;
			background: rgba(0, 0, 0, 0.3);
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.ico_1 {
			display: block;
			width: 36rpx;
			height: 36rpx;
		}

		.ico_2 {
			display: block;
			width: 40rpx;
			height: 40rpx;
		}
	} */
	.video_ph{
		width: 100%;
		height: 100vh;
		position: fixed;
		z-index: 1;
		left:0;
		top:0;
		right: 0;
		bottom: 0;
		.img{
			display: block;
			width: 100%;
			height: 100vh;
			object-fit: cover;
		}
	}
	.home_video {
		width: 100%;
		height: 100vh;
		overflow: hidden;
		position: relative;
		z-index: -1;
		.video_item{
			position: absolute;
			left:0;
			top:0;
			right:0;
			bottom: 0;
			width: 100%;
			height: 100vh;
			overflow: hidden;
		}
		.cover_ph {
			display: block;
			width: 100%;
			height: 100vh;
		}
	}

	/* 语音音阶------------- */
	.prompt-loader {
		height: 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 20rpx;

		.em {
			flex-shrink: 0;
			display: block;
			background: #3D3D3D;
			width: 4rpx;
			height: 10rpx;
			margin: 2rpx;
			border-radius: 2rpx;
			animation: load 1.5s infinite ease-in-out;

			&:nth-child(1) {
				animation-delay: 1.2s;
			}

			&:nth-child(2) {
				animation-delay: 0.9s;
			}

			&:nth-child(3) {
				animation-delay: 0.6s;
			}

			&:nth-child(4) {
				animation-delay: 0.3s;
			}

			&:nth-child(5) {
				animation-delay: 0.6s;
			}

			&:nth-child(6) {
				animation-delay: 0.9s;
			}

			&:nth-child(7) {
				animation-delay: 1.2s;
			}
		}
	}


	@keyframes load {
		0% {
			height: 10rpx;
		}

		50% {
			height: 30rpx;
		}

		100% {
			height: 10rpx;
		}
	}
	
	.three-dots {
	  --size: 20px;
	  display: inline-block;
	  font-size: var(--size);
	  height: var(--size);
	  line-height: var(--size);
	  overflow: hidden;
	  vertical-align: bottom;
	}

	.three-dots::after {
	  display: inline-block;
	  white-space: pre;
	  content: '\A.\A..\A...';
	  animation: loop 2s steps(4) infinite;
	}

	@keyframes loop {
	  to {
		transform: translateY(calc(0px - var(--size) * 4));
	  }
	}
	
	.expend{
		width: 624rpx;
		text-align: center;
		padding: 20rpx;
		.title{
			font-size: 40rpx;
			color: #FFFFFF;
			line-height: 60rpx;
			padding:40rpx 0 30rpx;
		}
		.text{
			color: #A1A1A1;
			font-size: 24rpx;
			line-height: 36rpx;
		}
		.num{
			display: flex;
			align-items: center;
			justify-content: center;
			padding-top: 20rpx;
			.ico{
				flex-shrink: 0;
				width: 100rpx;
				height: 100rpx;
				margin-right: 10rpx;
			}
			text{
				display: block;
				font-size: 80rpx;
				color: #FFFFFF;
				line-height: 100rpx;
			}
		}
		
		.btn{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 40rpx;
			padding: 5rpx;
			.btn_item{
				width: 100%;
				height: 100rpx;
				line-height: 100rpx;
				border-radius: 100rpx;
				box-sizing: border-box;
				font-size: 30rpx;
				color: #000;
				margin-bottom: 20rpx;
				&.hover{
					background-color: #F9BE01;
				}
			}
		}
	}
</style>